package com.ly.hotel.spainterface.jxd.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ly.hotel.R;
import com.ly.hotel.spainterface.nm.bean.XFBillBean;

import java.util.List;

public class XFBillAdapter extends BaseAdapter {
	Context mContext;
	LayoutInflater mInflater;
	private List<XFBillBean> xfBillList;

	public XFBillAdapter(Context c, List<XFBillBean> xfBillList) {
		this.xfBillList = xfBillList;
		mContext = c;
		mInflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		return xfBillList.size();
	}

	@Override
	public Object getItem(int postion) {
		return xfBillList.get(postion);
	}

	@Override
	public long getItemId(int postion) {
		return postion;
	}
	
	@Override
	public View getView(int postion, View contentView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if (contentView == null) {
			holder = new ViewHolder();
			contentView = mInflater.inflate(R.layout.xf_bill_item, null);
			holder.tv1 = contentView.findViewById(R.id.bill_item_text1);
			holder.tv2 = contentView.findViewById(R.id.bill_item_text2);
			holder.tv3 = contentView.findViewById(R.id.bill_item_text3);
			holder.tv4 = contentView.findViewById(R.id.bill_item_text4);
			holder.tv5 = contentView.findViewById(R.id.bill_item_text5);
			holder.tv6 = contentView.findViewById(R.id.bill_item_text6);
		} else {
			holder = (ViewHolder) contentView.getTag();
		}

		holder.tv1.setText(xfBillList.get(postion).getColumn1());
		holder.tv2.setText(xfBillList.get(postion).getColumn2());
		holder.tv3.setText(xfBillList.get(postion).getColumn3());
		holder.tv4.setText(xfBillList.get(postion).getColumn4());
		holder.tv5.setText(xfBillList.get(postion).getColumn5());
		holder.tv6.setText(xfBillList.get(postion).getColumn6());
		contentView.setTag(holder);
		return contentView;
	}

	static class ViewHolder {
		TextView tv1;
		TextView tv2;
		TextView tv3;
		TextView tv4;
		TextView tv5;
		TextView tv6;
	}
}
